package com.shine.rabbitmq.config;

import com.shine.rabbitmq.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author huihui
 * @date 2025/5/7 11:23
 * @description CommonLogConfig 公共API访问队列配置
 */
@Configuration
public class CommonLogConfig {

    @Bean
    public Queue commonLogQueue() {
        return new Queue(RabbitConstant.Gateway.COMMON_LOG_QUEUE);
    }

    @Bean
    public DirectExchange commonLogExchange() {
        return new DirectExchange(RabbitConstant.Gateway.COMMON_LOG_EXCHANGE);
    }

    @Bean
    public Binding commonLogBind() {
        return BindingBuilder.bind(commonLogQueue()).to(commonLogExchange()).with(RabbitConstant.Gateway.COMMON_LOG_KEY);
    }

}
